<?php
namespace app\admin\model;

use think\Model;
use think\Db;


class MwDb extends Model
{

    protected $connection = [
        // 数据库类型
        'type'        => 'mysql',
        // 数据库连接DSN配置
        'dsn'         => '',
        // 服务器地址
        'hostname'    => '127.0.0.1',
        // 数据库名
        'database'    => 'thinkphp',
        // 数据库用户名
        'username'    => 'root',
        // 数据库密码
        'password'    => '',
        // 数据库连接端口
        'hostport'    => '',
        // 数据库连接参数
        'params'      => [],
        // 数据库编码默认采用utf8
        'charset'     => 'utf8',
        // 数据库表前缀
        'prefix'      => 'think_',
    ];

    protected static  $conn = '';

    public function __construct($type='mysql',$host='127.0.0.1',$database,$user='root',$password='',$hostport='',$prefix='rs'){
        parent::__construct();
        $this->connection['type']=$type;
        $this->connection['hostname']=$host;
        $this->connection['database']=$database;
        $this->connection['username']=$user;
        $this->connection['password']=$password;
        $this->connection['hostpart']=$hostport;
        $this->connection['prefix']= $prefix;
        try {
            self::$conn = Db::connect($this->connection);
        } catch (Exception $e) {
            return $e->getMessage();
        }

    }

    public function getTableInfo($table){
        return  self::$conn->query("show full columns from ".$table);
    }



}